function savekeywords(a, b) {
  var c = $("input[name=keywordsCache]");
  tmp = eval("(" + c.val() + ")");
  tmp[a] = b;
  c.val(JSON.stringify(tmp));
}
function getkeywords(a) {
  var b = $("input[name=keywordsCache]").val();
  tmp = eval("(" + b + ")");
  return tmp[a];
}
function valnotnull(v) {
  return getkeywords(v) ? getkeywords(v) : "";
}
function getLabel(b) {
  var c = "";
  if (b && b != null && typeof b != "undefined") {
    var d = "";
    if (typeof b == "object") {
      $.each(b, function (i, a) {
        d = "";
        switch (a.style) {
          case "red":
            d = "";
            break;
          case "green":
            d = "layui-bg-green";
            break;
          case "orange":
            d = "layui-bg-orange";
            break;
          case "blue":
            d = "layui-bg-blue";
            break;
          default:
            d = "";
        }
        c += '<span class="layui-badge ' + d + '">' + a.name + "</span>&nbsp;";
      });
    }
  }
  return c;
}
function isMobileNumber(a) {
  var b = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  if (!b.test(a)) {
    return false;
  } else {
    return true;
  }
}
function gettreemenu(a, b) {
  var c = "[";
  for (var i = 0; i < a.length; i++) {
    var d = "";
    if (a[i].pid == b) {
      c +=
        '{name:"' +
        a[i].name +
        '",id:"' +
        a[i].id +
        '",icon:"' +
        a[i].icon +
        '"';
      d = gettreemenu(a, a[i].id);
      if (d.length > 10) {
        c += ",children:" + d;
      }
      c += "},";
    }
  }
  c += "]";
  return c;
}
function get_pid_name(a, b) {
  if (a && b) {
    for (var i = 0; i < a.length; i++) {
      if (a[i].id == b) {
        return a[i].name;
      }
    }
  }
  return "";
}
function get_pid_name_k(a, b, c) {
  if (a && b) {
    for (var i = 0; i < a.length; i++) {
      if (a[i].id == b) {
        return a[i][c];
      }
    }
  }
  return "";
}
function convertCurrency(a) {
  var e = "零壹贰叁肆伍陆柒捌玖".split(""),
    k = ["", "拾", "佰", "仟"],
    m = ["", "万", "亿", "兆"],
    n = ["角", "分", "毫", "厘"],
    b = "";
  if ("" == a) return "";
  a = parseFloat(a);
  if (1e15 <= a) return "";
  if (0 == a) return (b = e[0] + "元整");
  a = a.toString();
  if (-1 == a.indexOf(".")) var d = "";
  else (d = a.split(".")), (a = d[0]), (d = d[1].substr(0, 4));
  if (0 < parseInt(a, 10)) {
    for (var g = 0, l = a.length, c = 0; c < l; c++) {
      var f = a.substr(c, 1),
        h = l - c - 1,
        p = h / 4;
      h %= 4;
      "0" == f
        ? g++
        : (0 < g && (b += e[0]), (g = 0), (b += e[parseInt(f)] + k[h]));
      0 == h && 4 > g && (b += m[p]);
    }
    b += "元";
  }
  if ("" != d)
    for (k = d.length, c = 0; c < k; c++)
      (f = d.substr(c, 1)), "0" != f && (b += e[Number(f)] + n[c]);
  "" == b ? (b += e[0] + "元整") : "" == d && (b += "整");
  return b;
}
function getcarbrandselect(b, v) {
  for (
    var c = "", e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""), d = 0;
    d < e.length;
    d++
  ) {
    c += '<optgroup label="' + e[d] + '">';
    for (var a = 0; a < b.length; a++)
      b[a].code == e[d] &&
        (c +=
          '<option value="' +
          b[a].id +
          '" ' +
          (b[a].id == v ? "selected" : "") +
          ">" +
          b[a].name +
          "</option>");
    c += "</optgroup>";
  }
  return c;
}
String.prototype.replaceAll = function (a, b) {
  return this.replace(new RegExp(a, "gm"), b);
};
function getselectdefault(a, b) {
  var c = "";
  for (var i = 0; i < a.length; i++) {
    if (a[i].id == b) {
      c = a[i].name;
    }
  }
  if (b == 0) {
    c = "顶级分类";
  }
  return c;
}
function arr_qc(a) {
  var b = {};
  var c = [];
  for (var i = 0, len = a.length; i < len; i++) {
    if (!b[a[i]]) {
      c.push(a[i]);
      b[a[i]] = true;
    }
  }
  return c;
}
var dkdate = {
  formatDate: function (a) {
    var b = a.getFullYear();
    var c = a.getMonth() + 1;
    var d = a.getDate();
    if (c < 10) {
      c = "0" + c;
    }
    if (d < 10) {
      d = "0" + d;
    }
    return b + "-" + c + "-" + d;
  },
  getDaysInOneMonth(a, b) {
    var b1 = new Date(a, b, 1);
    var c1 = new Date(a, b + 1, 1);
    var d1 = (c1 - b1) / 86400000;
    return d1;
  },
  getQuarterStartMonth: function (a) {
    var b = 0;
    if (a < 3) {
      b = 0;
    }
    if (2 < a && a < 6) {
      b = 3;
    }
    if (5 < a && a < 9) {
      b = 6;
    }
    if (a > 8) {
      b = 9;
    }
    return b;
  },
  toDay: function () {
    var a = new Date();
    var d = this.formatDate(a);
    return d + " ～ " + d;
  },
  yesTerDay: function () {
    var a = new Date();
    var b = a.getFullYear();
    var c = a.getMonth();
    var d = a.getDate();
    var e = new Date(b, c, d - 1);
    var e = this.formatDate(e);
    return e + " ～ " + e;
  },
  thisWeek: function () {
    var a = new Date();
    var b = a.getFullYear();
    var c = a.getMonth();
    var d = a.getDate();
    var e = a.getDay();
    var f = new Date(b, c, d - e);
    var f = this.formatDate(f);
    var g = new Date(b, c, d + (6 - e));
    var g = this.formatDate(g);
    return f + " ～ " + g;
  },
  prevWeek: function () {
    var a = new Date();
    var b = a.getFullYear();
    var c = a.getMonth();
    var d = a.getDate();
    var e = a.getDay();
    var f = new Date(b, c, d - e - 7);
    var g = this.formatDate(f);
    var h = new Date(b, c, d - e - 1);
    var i = this.formatDate(h);
    return g + " ～ " + i;
  },
  thisMonth: function () {
    var a = new Date();
    var b = a.getFullYear();
    var c = a.getMonth();
    var d = new Date(b, c, 1);
    var d = this.formatDate(d);
    var e = new Date(b, c, this.getDaysInOneMonth(b, c));
    var e = this.formatDate(e);
    return d + " ～ " + e;
  },
  lastMonth: function () {
    var a = new Date();
    var b = a.getFullYear();
    var c = a.getMonth() + 1;
    var g = c;
    var d = 1;
    var e = new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    if (c == 1) {
      b = a.getFullYear() - 1;
      c = 12;
    } else {
      c = c - 1;
    }
    if ((b % 4 == 0 && b % 100 != 0) || b % 400 == 0) {
      e[2] = 29;
    }
    if (e[c] < d) {
      d = e[c];
    }
    if (d < 10) {
      d = "0" + d;
    }
    if (c < 10) {
      g = "0" + c;
    }
    var f = b + "-" + g + "-" + d;
    var h = f;
    var i = b + "-" + c + "-" + e[c];
    return h + " ～ " + i;
  },
  Quarter: function () {
    var a = new Date();
    var b = a.getFullYear();
    var c = a.getMonth();
    var d = new Date(b, this.getQuarterStartMonth(c), 1);
    var e = this.formatDate(d);
    var f = this.getQuarterStartMonth(c) + 2;
    let quarlastday = this.getDaysInOneMonth(b, f);
    var d = new Date(b, f, quarlastday);
    var g = this.formatDate(d);
    return e + " ～ " + g;
  }
};
function is_Array(a) {
  if (!Array.isArray) {
    return Object.prototype.toString.call(a) === "[object Array]";
  } else {
    return Array.isArray(a);
  }
}
var kobj = {
  isNull: function (a) {
    return null === a;
  },
  isUndefined: function (a) {
    return "undefined" === typeof a;
  },
  isBoolean: function (a) {
    return "boolean" == typeof a;
  },
  isNumber: function (a) {
    return "number" == typeof a;
  },
  isArray: function (a) {
    return "[object Array]" == Object.prototype.toString.call(a);
  },
  isString: function (a) {
    return "string" == typeof a;
  },
  isFunction: function (a) {
    return (
      "function" === typeof a ||
      "[object function]" == Object.prototype.toString.call(a)
    );
  },
  isObject: function (a) {
    return a && ("object" == typeof a || this.isFunction(a));
  },
  outString: function (a) {
    t = this;
    if (t.isNull(a) || t.isUndefined(a)) return "";
    return a;
  }
};

/**
 * 输出是否,用tag表示
 */
function yesno2tag(d) {
  if (d == 1 || d == 'true' || d == true) {
    return '<span class="layui-badge layui-bg-blue">是</span>';
  }
  return '<span class="layui-badge layui-bg-gray">否</span>';
}

/**
 * 输出是否,用tag表示
 */
function status2(d) {
  if (d == 1 || d == 'true' || d == true) {
    return '<span class="layui-badge layui-bg-blue">启用</span>';
  }
  return '<span class="layui-badge layui-bg-gray">禁用</span>';
}

/**
 * 1，2输出字,用tag表示
 */
function out2tag(yes, yestxt, notxt) {
  if (yes == 1 || yes == true) {
    return '<span class="layui-badge layui-bg-blue">' + yestxt + '</span>';
  } else if (yes == 2) {
    return '<span class="layui-badge layui-bg-gray">' + notxt + '</span>';
  }
  return '<span class="layui-badge layui-bg-gray">无</span>';
}

/**
 * 输出是否,用图标表示
 */
function yesno2icon(d) {
  if (d == 1 || d == 'true' || d == true) {
    return '<i class="layui-icon layui-icon-ok"></i>';
  }
  return '<i class="layui-icon layui-icon-close"></i>';
}

/**
 * 性别输出,用图标表示
 */
function sex2icon(sex) {
  if (sex === 1 || sex === '1') {
    return '<i class="fa fa-mars"></i>';
  } else if (sex === 2 || sex === '2') {
    return '<i class="fa fa-venus"></i>';
  }
  return '<i class="fa fa-genderless"></i>';
}
/**
 * 性别输出,用tag表示
 */
function sex2tag(sex) {
  if (sex === 1 || sex === '1') {
    return '<span class="layui-badge layui-bg-blue">♂</span>';
  } else if (sex === 2 || sex === '2') {
    return '<span class="layui-badge layui-bg-orange">♀</span>';
  }
  return '<span class="layui-badge layui-bg-black">○</span>';
}

//字符是否在字符串中,a,b有可能都是数组形式
function strIn(b, a) {
  if (a && a.indexOf(",") > -1) {
    a1 = a.split(",");
    t = false;
    if (b.indexOf(",") > -1) {
      a2 = b.split(",");
      t = true
    } else {
      t = false
        ; a2 = b
    }
    if (t) {
      layui.each(a2, function (d, c) {
        if (a1.indexOf(c) > -1) {
          return true
        }
      })
    } else {
      if (a1.indexOf(a2) > -1) {
        return true
      }
    }
  } else {
    if (a.indexOf(b) > -1) {
      return true
    }
  }
  return false
};

/**时间格式化 */
function dateFormat(b, a) {
  var c = {
    "M+": a.getMonth() + 1,
    "d+": a.getDate(),
    "h+": a.getHours(),
    "m+": a.getMinutes(),
    "s+": a.getSeconds(),
    "q+": Math.floor((a.getMonth() + 3) / 3),
    S: a.getMilliseconds()
  };
  /(y+)/.test(b) && (b = b.replace(RegExp.$1, (a.getFullYear() + "").substr(4 - RegExp.$1.length)));
  for (var d in c) (new RegExp("(" + d + ")")).test(b) && (b = b.replace(RegExp.$1, 1 == RegExp.$1.length ? c[d] : ("00" + c[d]).substr(("" + c[d]).length)));
  return b
};

function utime2str(ctime) {
  return dateFormat("yyyy-MM-dd hh:mm:ss", new Date(ctime * 1000))
}

function time2str1000(ctime) {
  return dateFormat("yyyy-MM-dd hh:mm", new Date(ctime * 1000))
}
function time2str(ctime) {
  return dateFormat("yyyy-MM-dd hh:mm", new Date(ctime))
}

/**
 * 文件大小单位格式化
 */
function files_size_format(a) {
  unit = "B KB MB GB TB PB EB ZB YB".split(" ");
  kb = 1024;
  i = Math.floor(Math.log(a) / Math.log(kb));
  return (a / Math.pow(kb, i)).toPrecision(3) + " " + unit[i];
}

function isSet(funcName) {
  try {
    if (typeof (eval(funcName)) == "function") {
      return true;
    }
  } catch (e) { }
  return false;
}
//获取地址栏参数
function getQueryString(name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if (r != null) return unescape(r[2]); return '';
}
//对字符串集合随机排列，随机输出指定的长度
function randomString(length) {
  var str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  var result = '';
  for (var i = length; i > 0; --i)
    result += str[Math.floor(Math.random() * str.length)];
  return result;
}

// 数组转tree
function list2Tree(list = []) {
  const data = JSON.parse(JSON.stringify(list)) // 浅拷贝不改变源数据
  const result = []
  if (!Array.isArray(data)) {
    return result
  }
  data.forEach(item => {
    delete item.children
  })
  const map = {}
  data.forEach(item => {
    map[item.id] = item
  })
  data.forEach(item => {
    const parent = map[item.pid]
    if (parent) {
      (parent.children || (parent.children = [])).push(item)
    } else {
      result.push(item)
    }
  })
  return result
}

//状态--统一
function statusTd(d) {
  if (typeof (d.status) === 'number') {
    switch (d.status) {
      case 0:
        return '<span class="layui-badge layui-bg-black">未提交</span>';
        break;
      case 1:
        return '<span class="layui-badge layui-bg-red">待审</span>';
        break;
      case 2:
        return '<span class="layui-badge layui-bg-green">通过</span>';
        break;
      case 3:
        return '<span class="layui-badge layui-bg-black">拒绝</span>';
        break;
      case 4:
        return '<span class="layui-badge layui-bg-black">退回</span>';
        break;
    }
  }
  return '';
}
//ids包含id
if (!idInIds) {
  function idInIds(id, ids) {
    if (typeof (ids) === 'string') {
      if (id) { id = id.toString(); } else { return false };
      var arr = ids.split(',');
      for (var i = 0; i < arr.length; i++) {
        if (id === arr[i].toString()) {
          return true;
        }
      }
    }
    return false;
  }
}
//取同步骤里多人的审核状态
function more_Status(id, json) {
  if (typeof (json) === 'string') {
    if (id) { id = id.toString(); } else { return 0 };
    var arr = JSON.parse(json);
    if (arr) {
      for (var i = 0; i < arr.length; i++) {
        if (id === arr[i]['audit_id'].toString()) {
          return arr[i]['status'] / 1;
        }
      }
    }
  }
  return 0;
}

// 定义还原html的方法
function htmlUnescape(html) {
  return html.replace(/&lt;|&gt;|&quot;|&amp;/g, match => {
    switch (match) {
      case '&lt;':
        return '<';
      case '&gt;':
        return '>';
      case '&quot;':
        return '"';
      case '&amp;':
        return '&';
    }
  })
}

//随机号
function randomNumber(str) {
  var outTradeNo = "";
  var date = new Date();
  for (var i = 0; i < 3; i++) //3位随机数，用以加在时间戳后面。
  {
    outTradeNo += Math.floor(Math.random() * 10);
  }
  var millisecond = date.getMilliseconds();
  var t = dateFormat("yyyyMMddhhmmss", date);
  outTradeNo = (str ? str : '') + '' +  t + '' + millisecond + '' + outTradeNo;
  return outTradeNo;
}

